package com.torches.cloud.service;

import com.torches.cloud.beans.User;
import com.torches.cloud.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author torches
 */
@Service
public class UserService {

    @Autowired
    UserMapper userMapper;

    // 判断是否存在该用户
    public boolean existUser(User user){
        User tempUser = userMapper.getUserByUserName(user.getUsername());
        return tempUser != null;
    }

    public void addUser(User user) {
        userMapper.addUser(user.getUsername(), user.getUsername(), user.getPassword());
    }

    public User login(User user){
        User tempUser = userMapper.getUserByPassword(user.getUsername(),user.getPassword());
        return tempUser;
    }


}
